﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.SqlClient;
using System.Data.EntityClient;

namespace kwzx.Data
{
    public class SCMDB : scm_mainEntities
    {
        public SCMDB()
            : base(GetCon())
        {

        }


        public static string GetCon()
        {

            // Specify the provider name, server and database.

            string providerName = "System.Data.SqlClient";
            string serverName = "10.35.3.37";
            string databaseName = "scm_main";

            // Initialize the connection string builder for the
            // underlying provider.
            SqlConnectionStringBuilder sqlBuilder =
                new SqlConnectionStringBuilder();

            // Set the properties for the data source.
            sqlBuilder.DataSource = serverName;
            sqlBuilder.InitialCatalog = databaseName;
            sqlBuilder.IntegratedSecurity = false;
            sqlBuilder.UserID = "sa";
            sqlBuilder.Password = "hxsa";

            // Build the SqlConnection connection string.
            string providerString = sqlBuilder.ToString();

            // Initialize the EntityConnectionStringBuilder.
            EntityConnectionStringBuilder entityBuilder =
                new EntityConnectionStringBuilder();

            //Set the provider name.
            entityBuilder.Provider = providerName;

            // Set the provider-specific connection string.
            entityBuilder.ProviderConnectionString = providerString;

            entityBuilder.Provider = providerName;

            // Set the Metadata location.
            //entityBuilder.Metadata = "res://*"; //或从.config文件中copy
            ////@"res://*/NBModel.csdl|
            ////res://*/NBModel.ssdl|
            ////res://*/NBModel.msl";
            entityBuilder.Metadata = "res://*/Data.ScmModel.csdl|res://*/Data.ScmModel.ssdl|res://*/Data.ScmModel.msl";
            string str = entityBuilder.ToString();
            return str;
        }
    }
}
